#include "custom_types.h"
#include <cuda_runtime.h>

#ifndef DEVICEFLOAT3
#define DEVICEFLOAT3
class DeviceFloat3{
public:
	inline DeviceFloat3(int size){
		cudaMalloc(&data, sizeof(float3) * size); 
		num = size;
	}

	inline ~DeviceFloat3(){
		cudaFree(data);
	}

	inline void insertDataFromHost(float3* in){
		insertData(in, cudaMemcpyHostToDevice);
	}

	inline void insertDataFromDevice(float3* in){
		insertData(in, cudaMemcpyDeviceToDevice);
	}

	inline void extractDataToHost(float3* out){
		extractData(out, cudaMemcpyDeviceToHost);
	}

	inline void extractDataToDevice(float3* out){
		extractData(out, cudaMemcpyDeviceToDevice);
	}		


protected:
	inline void insertData(float3* in, int mode){
		cudaMemcpy(data, in, sizeof(float3) * num, (cudaMemcpyKind)mode);
	}

	inline void extractData(float3* out, int mode){
		cudaMemcpy(out, data, sizeof(float3) * num, (cudaMemcpyKind)mode);
	}

	float3* data;
	int num;

};

#endif